import request from "@/util/request";
import {AxiosResponse} from "axios";

export const getHomeBanner = () => {
    return request({
        url: '/api/slider/getSliders',
        method: 'get'
    })
}

export const getMostNew = (data: { pageNum: number, pageSize: number }) => {
    return request({
        url: '/api/course/mostNew',
        method: 'post',
        data
    })
}

export const getFirstCategory = () => {
    return request({
        url: '/api/course/category/getFirstCategorys'
    })
}

export const getSecondCategory = (id: string): Promise<{
    data: {
        list: Array<any>
    }
}> => {
    return request({
        url: '/api/course/category/getSecondCategorys',
        method: 'get',
        params: {categoryId: id}
    })
}

interface CourseType {
    pageNum: number,
    pageSize: number,
    entity: {
        firstCategory: string
    }
}

export const getCourseList = (data: CourseType): Promise<AxiosResponse<{
    pageInfo:Array<any>
},any>> => {
    return request({
        url: '/api/course/search',
        method: 'post',
        data
    })
}
export const login = (data: { username: string, password: string }) => {
    return request({
        url: '/api/user/login',
        method: 'post',
        // params:data,
        data: data
    })
}